package com.mtconnect.common;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/1.
 */
public class Constant {

    /**
     * 表结构识别码
     */
    public static final String SAMPLE = "SAMPLE";
    public static final String EVENT = "EVENT";
    public static final String CONDITION = "CONDITION";

    /**
     * table prefix
     */
    public static final String PRE_SAMPLE = "S_";
    public static final String PRE_EVENT = "E_";
    public static final String PRE_CONDITION = "C_";

    /**
     * header element attribute name
     */
    public static final String CREATION_TIME = "creationTime";
    public static final String INSTANCE_ID = "instanceId";
    public static final String SENDER = "sender";
    public static final String BUFFER_SIZE = "bufferSize";
    public static final String ASSET_BUFF_SIZE = "assetBufferSize";
    public static final String LAST_SEQ = "lastSequence";
    public static final String NEXT_SEQ = "nextSequence";
    public static final String FIRST_SEQ = "firstSequence";
    public static final String VERSION = "version";
    public static final String ASSET_COUNT = "assetCount";

    /**
     * sequence prefix
     */
    public static final String SEQ_PREFIX = "seq_";

    public static final String DATA_ITEM = "DateItem";
    public static final String REFERENCE = "Reference";
    public static final String DEVICE = "Device";
    public static final String ERRORS = "Errors";
    public static final String ERROR = "Error";
    public static final String HEADER = "Header";
    public static final String ERROR_CODE = "errorCode";

    /**
     * Event string variable
     */
    public static final String UNAVAILABLE = "UNAVAILABLE";

    public static final String ACTUATOR_STATE = "ACTUATOR_STATE";

    public static final String AVAILABILITY = "AVAILABILITY";
    public static final String AVAILABLE = "AVAILABLE";

    public static final String AXIS_COUPLING = "AXIS_COUPLING";
    public static final String TANDEM = "TANDEM";
    public static final String SLAVE = "SLAVE";

    public static final String AXIS_INTERLOCK = "AXIS_INTERLOCK";

    public static final String AXIS_STATE = "AXIS_STATE";
    public static final String HOME = "HOME";
    public static final String TRAVEL = "TRAVEL";
    public static final String PARKED = "PARKED";

    public static final String CHUCK_INTERLOCK = "CHUCK_INTERLOCK";

    public static final String CHUCK_STATE = "CHUCK_STATE";
    public static final String OPEN = "OPEN";
    public static final String CLOSED = "CLOSED";
    public static final String UNLATCHED = "UNLATCHED";

    public static final String CONTROLLER_MODE = "CONTROLLER_MODE";
    public static final String AUTOMATIC = "AUTOMATIC";
    public static final String MANUAL = "MANUAL";
    public static final String MANUAL_DATA_INPUT = "MANUAL_DATA_INPUT";
    public static final String SEMI_AUTOMATIC = "SEMI_AUTOMATIC";
    public static final String EDIT = "EDIT";

    public static final String DIRECTION = "DIRECTION";
    public static final String ROTARY = "ROTARY";
    public static final String CLOCKWISE = "CLOCKWISE";
    public static final String COUNTER_CLOCKWISE = "COUNTER_CLOCKWISE";

    public static final String LINEAR = "LINEAR";
    public static final String POSITIVE = "POSITIVE";
    public static final String NEGATIVE = "NEGATIVE";

    public static final String DOOR_STATE = "DOOR_STATE";

    public static final String END_OF_BAR = "END_OF_BAR";
    public static final String YES = "YES";
    public static final String NO = "NO";

    public static final String EMERGENCY_STOP = "EMERGENCY_STOP";
    public static final String ARMED = "ARMED";
    public static final String TRIGGERED = "TRIGGERED";

    public static final String EXECUTION = "EXECUTION";
    public static final String INTERRUPTED = "INTERRUPTED";
    public static final String FEED_HOLD = "FEED_HOLD";
    public static final String STOPPED = "STOPPED";
    public static final String OPTIONAL_STOP = "OPTIONAL_STOP";
    public static final String PROGRAM_STOPPED = "PROGRAM_STOPPED";
    public static final String PROGRAM_COMPLETED = "PROGRAM_COMPLETED";

    public static final String FUNCTIONAL_MODE = "FUNCTIONAL_MODE";
    public static final String PRODUCTION = "PRODUCTION";
    public static final String SETUP = "SETUP";
    public static final String TEARDOWN = "TEARDOWN";
    public static final String MAINTENANCE = "MAINTENANCE";
    public static final String PROCESS_DEVELOPMENT = "PROCESS_DEVELOPMENT";

    public static final String INTERFACE_STATE = "INTERFACE_STATE";
    public static final String ENABLED = "ENABLED";
    public static final String DISABLED = "DISABLED";

    public static final String PART_COUNT = "PART_COUNT";

    public static final String PATH_MODE = "PATH_MODE";
    public static final String INDEPENDENT = "INDEPENDENT";
    public static final String MASTER = "MASTER";
    public static final String SYNCHRONOUS = "SYNCHRONOUS";
    public static final String MIRROR = "MIRROR";

    public static final String POWER_STATE = "POWER_STATE";
    public static final String ON = "ON";
    public static final String OFF = "OFF";

    public static final String ROTARY_MODE = "ROTARY_MODE";
    public static final String SPINDLE = "SPINDLE";
    public static final String INDEX = "INDEX";
    public static final String CONTOUR = "CONTOUR";

    public static final String SPINDLE_INTERLOCK = "SPINDLE_INTERLOCK";
    public static final String ACTIVE = "ACTIVE";
    public static final String INACTIVE = "INACTIVE";

    public static final String MATERIAL_FEED = "MATERIAL_FEED";
    public static final String NOT_READY = "NOT_READY";
    public static final String READY = "READY";
    public static final String FAIL = "FAIL";
    public static final String COMPLETE = "COMPLETE";

    public static final String MATERIAL_CHANGE = "MATERIAL_CHANGE";
    public static final String MATERIAL_RETRACT = "MATERIAL_RETRACT";
    public static final String MATERIAL_LOAD = "MATERIAL_LOAD";
    public static final String MATERIAL_UNLOAD = "MATERIAL_UNLOAD";
    public static final String PART_CHANGE = "PART_CHANGE";
    public static final String OPEN_DOOR = "OPEN_DOOR";
    public static final String CLOSE_DOOR = "CLOSE_DOOR";
    public static final String OPEN_CHUCK = "OPEN_CHUCK";
    public static final String CLOSE_CHUCK = "CLOSE_CHUCK";

    /**
     * Condition string variable
     */
    public static final String FAULT = "FAULT";
    public static final String WARNING = "WARNING";
    public static final String NORMAL = "NORMAL";
    public static final String HIGH = "HIGH";
    public static final String LOW = "LOW";


    /**
     * xsd 位置
     */
    public static final String DEVICE_PATH = "file:" + getPath() + "schemas/MTConnectDevices_1.3.xsd";
    public static final String ASSET_PATH = "file:" + getPath() + "schemas/MTConnectAssets_1.3.xsd";

    /**
     * xpath命名空间
     */
    public static final Map< String,  String> DEVICE_XMLNS = new HashMap<String,  String>(){{
        put("d", "urn:mtconnect.org:MTConnectDevices:1.3");
    }};
    public static final Map< String,  String> ASSET_XMLNS = new HashMap<String,  String>(){{
        put("a", "urn:mtconnect.org:MTConnectAssets:1.3");
    }};

    public static final long MAX_SEQUENCE = 4294967294L;
    /**
     * 拿到当前项目的类路径
     *
     * @return 返回当前项目的绝对类路径
     */
    public static String getPath() {
        URL resource = Constant.class.getClassLoader().getResource("");
        return resource.getPath();
    }
}
